'''
Created on Feb 6, 2011

@author: inyaky
'''

from google.appengine.ext.webapp import template
from model.fields.uBlobTaskField import BlobTaskField
from model.uUserAdapter import UserAdapter
from view.renderers.uRenderable import Renderable
import os
import uConst

class NewTaskRen(Renderable):

    def __init__(self,aEnviroment, aTask):
        self._enviroment = aEnviroment
        self._taskToRender = aTask
        
        
        
    
    def render(self):
        
        user = UserAdapter(self._enviroment)
        
        if user.isLogged() :
            
            category_list = []
            for aCategory in user.getCategoryList():
                category_list = category_list + aCategory.toRenderable()
            
            values = {
                      'draw_task_creater':True,
                      'task_to_edit':self._taskToRender.toRenderable(False)[0],
                      'user':user.toRenderable(),
                      'category_list':category_list,
            } 
            
            path = os.path.join(self._enviroment.path, uConst.INDEX)
            self._enviroment.response.out.write(template.render(path, values))
        
        else:
            user.LogIn()
            